# 中心位置所在图片百分比
center_x = 0.5
center_y = 200 / 720

# 输入像素
high = 720
width = 960

# 相机焦距(像素)
f = 900

# 圆半径(cm)
cr = 40


class Center_tool:
    x = -1
    y = -1
    r = -1
    cx = -1
    cy = -1
    d = -1

    def __init__(self):
        self.cx = width / 2
        self.cy = high / 2

    def set(self, x=-1, y=-1, r=-1):
        self.x = x
        self.y = y
        self.r = r
        self.get_d()

    def get_d(self):
        self.d = cr / self.r * f
        return int(self.d)

    def get_X_move(self):
        """
        无人机需要移动距离
        左为负,右为正
        返回cm
        :return:
        """
        dx = self.x - self.cx
        mx = dx / f * self.d
        return int(mx)

    def get_Y_move(self):
        """
        无人机需要移动距离
        上为正,下为负
        返回cm
        :return:
        """
        dy = self.y - self.cy
        my = dy / f * self.d
        return int(my)
